package com.acyouzi.huawei;

import java.util.HashMap;
import java.util.Scanner;

/**
 * 17/9/26 19:01
 *
 * @author sunxu
 */
public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    StringBuilder builder1 = new StringBuilder(in.nextLine());
    StringBuilder builder2 = new StringBuilder(in.nextLine());
    HashMap<Character,Integer> map = new HashMap<>();
    for (int i = 0; i < builder1.length(); i++) map.put(builder1.charAt(i),0);
    for (int i = 0; i < builder2.length(); i++) {
      if (map.containsKey(builder2.charAt(i))){
        map.put(builder2.charAt(i),1);
        builder2.deleteCharAt(i);
        builder2.insert(i,'_');
      }
    }
    for (int i = 0; i < builder1.length(); i++) {
      if (map.containsKey(builder1.charAt(i)) && map.get(builder1.charAt(i)) == 1){
        builder1.deleteCharAt(i);
        builder1.insert(i,'_');
      }
    }
    System.out.println(builder1);
    System.out.println(builder2);
  }
}
